<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>增加</title>
</head>
<body>
    <table>
        <tr>
            <td>标题</td>  
            <td><input type="text" id="title"></td>
        </tr>
        <tr>
            <td>摘要</td>  
            <td><input type="text" id="abstract"></td>
        </tr>
        <tr>
            <td>内容</td>  
            <td><input type="text" id="content"></td>
        </tr>
        <tr>
            <td>分类</td>  
            <td><input type="text" id="classify"></td>
        </tr>

        <tr>
            <td>作者</td>  
            <td><input type="text" id="author"></td>
            
        </tr>

       
           
     
    </table>
    <input type="button" value="保存" onclick="add()">
    <input type="button" value="返回" onclick="cancel()"> 
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script>
        //获取到之后post
        
        function add(){
        let title = $("#title").val();
        let abstract = $("#abstract").val();
        let content = $("#content").val();
        let classify = $("#classify").val();
        let author = $("#author").val();
        let obj={title,abstract,content,classify,author}
            $.post("http://localhost:3000/blogs", obj, function (res) {
                    alert("增加成功！")
                    window.location.href = "./index.html"
                })

            }
            function cancel(){
            location.href="./index.html"
        }
    </script>    
</body>
</html>